package com.wechat.ferry.strategy.msg.receive.impl;

import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson2.JSONObject;
import com.wechat.ferry.entity.dto.WxPpMsgDTO;
import com.wechat.ferry.entity.vo.request.WxPpWcfReceiveTransferReq;
import com.wechat.ferry.entity.vo.request.WxPpWcfSendTextMsgReq;
import com.wechat.ferry.enums.ReceiveMsgChannelEnum;
import com.wechat.ferry.enums.WcfMsgTypeEnum;
import com.wechat.ferry.service.WeChatDllService;
import com.wechat.ferry.strategy.msg.receive.ReceiveMsgStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 策略实现类-接收消息-签到处理
 *
 * @author chandler
 * @date 2024-12-25 14:19
 */
@Slf4j
@Component
public class TransferMsgStrategyImpl implements ReceiveMsgStrategy {

    @Autowired
    private WeChatDllService weChatDllService;

    @Override
    public String getStrategyType() {
        return WcfMsgTypeEnum.SHARE.getCode();
    }

    @Override
    public String doHandle(WxPpMsgDTO dto) {
//        if (dto.getContent().contains("转账")) {
//            log.info("转账处理");
//            //调用转账接口
//            WxPpWcfReceiveTransferReq rep = new WxPpWcfReceiveTransferReq();
//            String transferId = Convert.toStr(((JSONObject) (((JSONObject) (((JSONObject) dto.getJsonContent().get("msg")).get("appmsg"))).get("wcpayinfo"))).get("transferid"));
//            String transactionId = Convert.toStr(((JSONObject) (((JSONObject) (((JSONObject) dto.getJsonContent().get("msg")).get("appmsg"))).get("wcpayinfo"))).get("transcationid"));
//            rep.setWeChatUid(dto.getSender());
//            rep.setTransferId(transferId);
//            rep.setTransactionId(transactionId);
//            weChatDllService.receiveTransfer(rep);
//            //在发送消息
//            WxPpWcfSendTextMsgReq wxPpWcfSendTextMsgReq = new WxPpWcfSendTextMsgReq();
//            wxPpWcfSendTextMsgReq.setMsgText("转账接收成功-来自机器人自动接收");
//            wxPpWcfSendTextMsgReq.setRecipient(dto.getSender());
//            weChatDllService.sendTextMsg(wxPpWcfSendTextMsgReq);
//            return "接收转账成功";
//        }
        return "";
    }

}
